home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
DESK
/
CORE
/
Desk
/
h_doc
/
Coord
< prev
next >
Wrap
Text File
|
1996-05-21
|
9KB
|
277 lines
/*
#### # # # #
# # # # # The FreeWare C library for
# # ## ### # # # # ### RISC OS machines
# # # # # # # # # # # ___________________________________
# # #### ### ## # # # #
# # # # # # # # # # Please refer to the accompanying
#### ### #### # # ##### # ### documentation for conditions of use
________________________________________________________________________
File: Coord.h
Author: Copyright © 1992, 1993, 1994 Edouard Poor, Jason Williams
and Tim Browse
Version: 1.02 (02 Mar 1994)
Purpose: Coord (point and rectangle) handling functions
*/
#ifndef __Desk_Coord_h
#define __Desk_Coord_h
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __Desk_core_h
#include "Core.h"
#endif
#ifndef __Desk_Wimp_h
#include "Wimp.h"
#endif
typedef struct
{
Desk_wimp_rect screenrect;
Desk_wimp_point scroll;
} Desk_convert_block;
extern Desk_bool Desk_Coord_PointInRect( const Desk_wimp_point *point, const Desk_wimp_rect *rect);
/*
Inputs: point - the point to test
rect - the rectangle to check for containment with.
Returns: Desk_bool_TRUE if point is in rectangle; Desk_bool_FALSE otherwise.
Purpose: Tests whether the point is within the rectangle. If it's on the
line it's counted as in (just like in tennis).
SeeAlso: Desk_Coord_RectContained; Desk_Coord_RectsOverlap
*/
extern Desk_bool Desk_Coord_RectContained( const Desk_wimp_rect *InsideRect,
const Desk_wimp_rect *OutsideRect);
/*
Inputs: See purpose.
Returns: Desk_bool_TRUE if InsideRect is withing OutsideRect;
Desk_bool_FALSE otherwise.
Purpose: Test whether the InsideRect is wholly contained by the
OutsideRect. Shared vertices/edges are considered to be inside.
SeeAlso: Desk_Coord_PointInRect; Desk_Coord_RectsOverlap
*/
extern Desk_bool Desk_Coord_RectsOverlap( const Desk_wimp_rect *rect1, const Desk_wimp_rect *rect2);
/*
Inputs: rect1, rect2 - the rectangles to check for overlap.
Returns: Desk_bool_TRUE if rectangles overlap;
Desk_bool_FALSE otherwise.
Purpose: Checks to see if two rectangles overlap each other in any
way (includes containment).
SeeAlso: Desk_Coord_RectsIntersect
*/
#define Desk_Coord_RectsIntersect(r1, r2) (Desk_Coord_RectsOverlap(r1, r2) && \
!Desk_Coord_RectContained(r1, r2) && \
!Desk_Coord_RectContained(r2, r1))
/*
MACRO: Desk_bool Desk_Coord_RectsIntersect(Desk_wimp_rect *rect1, Desk_wimp_rect *rect2)
Inputs: rect1, rect2 - the rectangles to check for intersection
Returns: Desk_bool_TRUE if rectangles intersect but do not contain each other;
Desk_bool_FALSE otherwise.
Purpose: Tests if two rectangles intersect each other, but wil return
failure if either rectangle wholly contains the other one.
This is different to the behaviour of Desk_Coord_RectsOverlap.
SeeAlso: Desk_Coord_RectsOverlap
*/
/*K**************************************************************************
> Coordinate conversion.
Screen <---> Work Area conversion routines.
NOTE:
"Screen Coordinates" refers to OS coordinates, with the bottom
left corner of the screen being placed at the screen origin, (0, 0)
"Work Area Coordinates" refers to Coordinates within the Window's
work area, where the (0, 0) origin is at the TOP left of the work area
Some of these routines have been defined as macros because they are
very elementary, and are common, so efficiency will be improved by
removing the function call overhead.
To keep compatibility with the syntax of Acorn's Desk_coords_ calls, these
macros still accept a pointer to a Desk_convert_block.
****************************************************************************/
extern void Desk_Coord_WindowOrigin( Desk_wimp_point *origin, const Desk_convert_block *convert);
/*
Inputs: convert - the standard Desk_convert_block.
Outputs: origin - the window origin, in screen coordinates.
Purpose: Returns the origin (TOP LEFT (0, 0) corner) of the window's
work-area in screen coordinates. This can then be used as a
redraw-origin for redraws - any drawing done relative to this
origin will appear at the correct screen position regardless of
scroll bar offsets and screen position of the window.
Remember to call this at the start of each redraw - whenever the
window is moved or scrolled, the position of this origin (in
screen coordinates) will change, so it must be recalculated.
SeeAlso: Desk_Coord_PointToScreen
*/
#define Desk_Coord_XToScreen(X, C) \
(((X) - (C)->scroll.x) + (C)->screenrect.min.x)
/*
MACRO: int Desk_Coord_XToScreen(int xpos, Desk_convert_block *convert)
Inputs: xpos - the x coordinate to translate.
convert - the standard Desk_convert_block.
Returns: The translated x coordinate.
Purpose: Translate a x coordinate from the work-area to the screen
coordinate space.
SeeAlso: Desk_Coord_PointToScreen; Desk_Coord_YToScreen
*/
#define Desk_Coord_YToScreen(Y, C) \
( ((Y) - (C)->scroll.y) + (C)->screenrect.max.y )
/*
MACRO: int Desk_Coord_YToScreen(int ypos, Desk_convert_block *convert)
Inputs: ypos - the y coordinate to translate.
convert - the standard Desk_convert_block.
Returns: The translated y coordinate.
Purpose: Translate a y coordinate from the work-area to the screen
coordinate space.
SeeAlso: Desk_Coord_PointToScreen; Desk_Coord_XToScreen
*/
extern void Desk_Coord_PointToScreen(Desk_wimp_point *point, const Desk_convert_block *convert);
/*
Inputs: point - a point in Work Area coords.
convert - the standard Desk_convert_block.
Outputs: point - the same point in screen coordinates
Purpose: Convert a work-area coordinate to a screen coordinate.
SeeAlso: Desk_Coord_RectToScreen; Desk_Coord_XToScreen; Desk_Coord_YToScreen;
Desk_Coord_PointToWorkArea
*/
extern void Desk_Coord_RectToScreen(Desk_wimp_rect *rect, const Desk_convert_block *convert);
/*
Inputs: rect - a rectangle in Work Area coords.
convert - the standard Desk_convert_block.
Outputs: rect - the same rectangle in screen coordinates
Purpose: Convert a rectangle in work-area coordinates to screen
coordinates.
SeeAlso: Desk_Coord_PointToScreen
*/
#define Desk_Coord_XToWorkArea(X, C) (((X)-(C)->screenrect.min.x)+(C)->scroll.x)
/*
MACRO: int Desk_Coord_XToWorkArea(int xpos, Desk_convert_block *convert)
Inputs: xpos - the screen x coordinate to convert.
convert - the standard Desk_convert_block.
Returns: The x coordinate translated to work-area coordinates.
Purpose: Convert an x coordinate from the screen coordinate space to
the work-area coordinate space.
SeeAlso: Desk_Coord_YToWorkArea; Desk_Coord_PointToWorkArea
*/
#define Desk_Coord_YToWorkArea(Y, C) (((Y)-(C)->screenrect.max.y)+(C)->scroll.y)
/*
MACRO: int Desk_Coord_YToWorkArea(int ypos, Desk_convert_block *convert)
Inputs: ypos - the screen y coordinate to convert.
convert - the standard Desk_convert_block.
Returns: The y coordinate translated to work-area coordinates.
Purpose: Convert an y coordinate from the screen coordinate space to
the work-area coordinate space.
SeeAlso: Desk_Coord_XToWorkArea; Desk_Coord_PointToWorkArea
*/
extern void Desk_Coord_PointToWorkArea(Desk_wimp_point *point,
const Desk_convert_block *convert);
/*
Inputs: point - a point in screen coords.
convert - the standard Desk_convert_block.
Outputs: point - the same point in work area coords.
Purpose: Convert a coordinate from the screen coordinate space to the
work-area coordinate space.
SeeAlso: Desk_Coord_PointToScreen; Desk_Coord_RectToWorkArea
*/
extern void Desk_Coord_RectToWorkArea(Desk_wimp_rect *rect, const Desk_convert_block *convert);
/*
Inputs: rect - a rectangle in screen coords.
convert - the standard Desk_convert_block.
Outputs: rect - the same rectangle in work area coords.
Purpose: Convert a rectangle from the screen coordinate space to the
work-area coordinate space.
SeeAlso: Desk_Coord_PointToWorkArea; Desk_Coord_RectToScreen
*/
extern void Desk_Coord_RectUnion(Desk_wimp_rect *dest,
Desk_wimp_rect *src1, Desk_wimp_rect *src2);
/*
Inputs: src1, src2 - the two rectangles to find the union of.
Outputs: dest - the rectangle structure to hold the union.
Purpose: Find the union of two rectangles. dest can be the same as
either src1 or src2 if you want to use this as an
accumulator. (dest can be the same as src1 *and* src2, if
you're feeling really silly).
SeeAlso: Desk_Coord_RectsOverlap; Desk_Coord_RectsIntersect
*/
#ifdef __cplusplus
}
#endif
#endif